<script>
    $(function () {
        <#list table.fields as field>
        <#if field.propertyName == "locationId">

        var provinceId = ${r'${(provinceId)!0}'};
        var cityId = ${r'${(cityId)!0}'};
        var locationId = ${r'${(locationId)!0}'};
        </#if>
        </#list>

        formValidate("#${serviceNameSimple}EditForm", {
        <#list table.fields as field>
        <#if field.propertyName == "idx" || field.propertyName == "createTime">
        <#else>
            ${field.propertyName}: {
                required: <#if field.nullable>false<#else>true</#if>,
                maxlength: ${field.length}
            },
        </#if>
        </#list>
        })

        <#list table.fields as field>
        <#if field.propertyName == "locationId">
        $("#${serviceNameSimple}EditForm #provinceId").change(function () {
            locationOptions("#${serviceNameSimple}EditForm #cityId", $(this).val(), cityId, true);
            cityId = 0;
        });
        $("#${serviceNameSimple}EditForm #cityId").change(function () {
            locationOptions("#${serviceNameSimple}EditForm #locationId", $(this).val(), locationId, true);
            locationId = 0;
        });
        locationOptions("#${serviceNameSimple}EditForm #provinceId", 0, provinceId, true);
        provinceId = 0;
        </#if>
        </#list>
    });

    function ${serviceNameSimple}SubmitForm(parentIndex) {
        var s = $("#${serviceNameSimple}EditForm").validate().form();
        if (s) {
            commonAjaxJson("${r'${rc.contextPath}'}/${table.controllerPath}/save", $("#${serviceNameSimple}EditForm").serializeArray(), function (data) {
                closeMsg(parentIndex);
                layer.msg("保存成功");
                $('#${serviceNameSimple}SearchTable').bootstrapTable("refresh");
            });
        }
    }
</script>

<div style="width:650px;padding:15px;height:auto;overflow:auto;">
    <form class="form-horizontal" id="${serviceNameSimple}EditForm">
        <input type="hidden" name="idx" value="${r'${'}(${serviceNameSimple}.idx)!}">
        <#list table.fields as field>
        <#if field.propertyName == "idx" || field.propertyName == "createTime">
        <#else>
        <div class="form-group">
            <label class="col-xs-3 control-label<#if !(field.nullable)> red-star-before</#if>">${field.comment}</label>
            <#if field.propertyName == "status">
            <div class="col-xs-8">
                <select class="form-control" name="status" id="status">
                    ${r'[#list status as s]'}
                    <option value="${r'${s}'}" ${'[#if'} s==${serviceNameSimple}.status]selected=selected${'[/#if]'}>${r'${'}s.desc}</option>
                    ${r'[/#list]'}
                </select>
            <#elseif field.propertyName == "yesNo">
            <div class="col-xs-8">
                <select class="form-control" name="yesNo" id="yesNo">
                    ${'[#list yesNo as s]'}
                    <option value="${r'${s}'}" ${r'[#if'} s==${serviceNameSimple}.yesNo]selected=selected${'[/#if]'}>${r'${s'}.desc}</option>
                    ${'[/#list]'}
                </select>
            <#elseif field.propertyName == "locationId">
            <div class="input-group col-xs-8" style="padding: 0 15px;">
                <select name="provinceId" id="provinceId" class="form-control width-32"></select>
                <select name="cityId" id="cityId" class="form-control width-32" style="margin:0 2%;"></select>
                <select name="locationId" id="locationId" class="form-control width-32"></select>
            <#else>
            <div class="col-xs-8">
                <input type="text" class="form-control" placeholder="${field.comment}" name="${field.propertyName}" id="${field.propertyName}" autocomplete="off" value="${r'${'}${serviceNameSimple}.${field.propertyName}}">
            </#if>
            </div>
        </div>
        </#if>
        </#list>
    </form>
</div>
